package com.soft.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.soft.entity.Sushe;
import com.soft.mapper.SusheMapper;

@Service
public class SusheService {
    @Autowired
    private SusheMapper susheMapper;

    public List<Sushe> queryAll() {
        List<Sushe> susheList = susheMapper.selectList(null);
        return susheList;
    }
 // 根据capacity的名字进行查询
    public List<Sushe> queryByCapacity(String capacityName) {
    	QueryWrapper<Sushe> qw = new QueryWrapper();
        qw.eq("sushe_capacity", capacityName);
        List<Sushe> deptList = susheMapper.selectList(qw);
        return deptList;
    }
    public int insertOne(String floorName, String capacityName) {
        Sushe sushe = new Sushe();
        sushe.setSusheFloor(floorName);
        sushe.setSusheCapacity(capacityName);
        int num = susheMapper.insert(sushe);
        return num;
    }
    public int deleteOne(String Sno) {
    	Sushe sushe = new Sushe();
	    sushe.setSusheSno(Sno);
	    int num=susheMapper.deleteById(sushe);
	    return num;
    }
    public int deleteTwo(String f2) {
    	QueryWrapper<Sushe> qw = new QueryWrapper();
		qw.eq("sushe_floor", f2);
		int num=susheMapper.delete(qw);
		return num;
	}
    public int updateOne(String f2) {
    	Sushe sushe = new Sushe();
	    sushe.setSusheSno(f2);
	    sushe.setSusheFloor("aaaa");
	    sushe.setSusheCapacity("aaaa");
	    int num=susheMapper.updateById(sushe);
	    return num;
	}
    public int updateTwo(String f2) {
    	QueryWrapper<Sushe> uw = new QueryWrapper();
        uw.gt("sushe_sno", f2);
        Sushe sushe = new Sushe();
        sushe.setSusheCapacity("hhhhhhhhhh");
        susheMapper.update(sushe,uw);
        int num = susheMapper.update(sushe,uw);
        return num;
        
	}
    
    
}